package com.snoob.serviceEnterprise.enterprise.controller;

import com.snoob.serviceEnterprise.enterprise.entity.EnterpriseEntity;
import com.snoob.serviceEnterprise.enterprise.service.EnterpriseService;
import com.snoob.springcloudalibaba.base.BasePageResult;
import com.snoob.springcloudalibaba.pipleline.qo.SelectEnterpriseQo;
import com.snoob.springcloudalibaba.pipleline.vo.DeleteEnterpriseVoReq;
import com.snoob.springcloudalibaba.pipleline.vo.InsertEnterpriseVoReq;
import com.snoob.springcloudalibaba.pipleline.vo.UpdateEnterpriseVoReq;
import com.snoob.springcloudalibaba.util.ConvertUtils;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @描述：企业
 * @作者：lixing_java@163.com
 * @时间：2022/5/14 16:16
 */
@RestController
@RequestMapping("/enterprise")
@Component
public class EnterpriseController {
    @Resource
    private EnterpriseService enterpriseService;

    /**
     * @描述 添加企业信息
     */
    public String insertEnterprise(InsertEnterpriseVoReq vo) {
        EnterpriseEntity enterpriseEntity = ConvertUtils.convert(vo, EnterpriseEntity.class);
        String enterpriseCode = enterpriseService.insertEnterprise(enterpriseEntity);
        return enterpriseCode;
    }

    /**
     * @描述 编辑企业信息
     */
    public Boolean updateEnterprise(UpdateEnterpriseVoReq vo) {
        EnterpriseEntity enterpriseEntity = ConvertUtils.convert(vo, EnterpriseEntity.class);
        Boolean flag = enterpriseService.updateEnterprise(enterpriseEntity);
        return flag;
    }

    /**
     * @描述 删除企业信息
     */
    public Boolean deleteEnterprise(DeleteEnterpriseVoReq vo) {
        return enterpriseService.deleteEnterprise(vo);
    }

    /**
     * @描述 查询企业信息
     */
    public EnterpriseEntity selectEnterprise(SelectEnterpriseQo qo) {
        return enterpriseService.selectEnterprise(qo);
    }

    /**
     * @描述 分页查询企业信息
     */
    public BasePageResult<EnterpriseEntity> selectEnterpriseByPage(SelectEnterpriseQo qo) {
        return enterpriseService.selectEnterpriseByPage(qo);
    }
}

